﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PuroGame.Model.Mercadao;

namespace MercadaoPuroGame.Web.Controllers
{
    public class UsuarioController : Controller
    {
        //
        // GET: /Usuario/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Cadastro()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Cadastrar(PuroGame.ViewData.Mercadao.UsuarioViewData model)
        {
            //PuroGame.Model.Mercadao.UsuarioModel _model = new PuroGame.Model.Mercadao.UsuarioModel();
            //_model.CadastrarUsuario(model);
            return View("Index");
        }

        public ActionResult Login(PuroGame.ViewData.Mercadao.UsuarioViewData model)
        {
            UsuarioModel _model = new UsuarioModel();
            _model.CarregarDados(ref model);

            if (model.ID > 0)
        {
                HttpCookie cookie = new HttpCookie("purogame");
                cookie.Expires = DateTime.Now.AddMinutes(3);
                cookie.Values.Add("ID", model.ID.ToString());
                cookie.Values.Add("Nome", model.Nome);
                Response.Cookies.Add(cookie);
            }

            return View();
        }
    }
}
